package com.dispatcher;

import zxing.library.DecodeCallback;
import zxing.library.ZXingFragment;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.view.View;
import android.view.WindowManager;

import com.google.zxing.Result;

public class Activity_ScanQRcode extends ActivityBase 
{
	ZXingFragment zxing;
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//去掉信息栏
		setContentView(R.layout.scan_qrcode);
		FragmentManager fragmentManager =this.getSupportFragmentManager();  
		FragmentTransaction fragmentTransaction =fragmentManager.beginTransaction();  
		zxing=(ZXingFragment)fragmentManager.findFragmentById(R.id.scanner);
		zxing.setDecodeCallback(new DecodeCallback() {
			public void handleBarcode( Result result, Bitmap barcode, float scaleFactor ){
				Intent data=new Intent();
				data.putExtra("rststr", result.getText());
				setResult(RESULT_OK, data);
				finish();
//				Toast.makeText(Activity_ScanQRcode.this, result.getText(), Toast.LENGTH_LONG).show();
//				zxing.restartScanning();
			}
		});
//		zxing.restartScanning();
	}
	
	public void onClick(View v) {
		switch(v.getId()){
		
		default:
			break;
		}	
	}

	
	

}